package com.sihan.framework.etm.mapper.baseData;

import com.framework.mybatis.mapper.BaseMapper;
import com.sihan.framework.etm.dto.DeviceRecordDTO;
import com.sihan.framework.etm.dto.baseData.DeviceDTO;
import com.sihan.framework.etm.entity.baseData.DeviceCoordinateRecordModel;
import com.sihan.framework.etm.entity.baseData.DeviceModel;
import com.sihan.framework.etm.entity.baseData.DeviceModelDTO;
import com.sihan.framework.etm.entity.business.DeviceStatistics;
import com.sihan.framework.etm.vo.baseData.DeviceVO;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;


@Mapper
public interface DeviceMapper extends BaseMapper<DeviceModel, String> {

    List<DeviceVO> selectPage(@Param("param") DeviceDTO dto, @Param("orgIds") String[] orgIds);

    List<DeviceCoordinateRecordModel> setectList(@Param("deviceId")String deviceId,
                                              @Param("queryStartTime") Date queryStartTime,
                                              @Param("queryEndTime") Date queryEndTime);



    List<DeviceVO> selectPages(@Param("orgId") String orgId,
                               @Param("code") String devcode,
                               @Param("name") String devname,
                               @Param("queryStartTime") Date queryStartTime,
                               @Param("queryEndTime") Date queryEndTime);

    DeviceVO selectDetailInfo(@Param("id") String id);

    int selectAllByCodeInt(@Param("str")String str);
    //Integer selectAllByCodeInt();

    List<String> getAllDeviceCode(@Param("stat") Integer stat);

    List<DeviceModel> selectListALL(@Param("orgIds") String[] orgIds);

    void updateDeviceToUnline();

    /**
     * @param codes
     * @return
     * @return List<String>
     * @description 查询未关门的柜子
     * @auther 韩兵
     * @Date 2020年9月24日
     */
    List<String> selectUnlockDevice(@Param("codes") List<String> codes);

    void updateDeviceVoltageAndCountByImei(@Param("voltage") Double voltage, @Param("sendCount") Integer sendCount, @Param("imei") String imei);

    List<DeviceStatistics> getLastInsert(@Param("orgId") String orgId);

    List<DeviceModelDTO> getListDeviceModelDTO(@Param("deviceName") String deviceName,
                                               @Param("deviceCode") String deviceCode,
                                               @Param("orgIds") String[] orgIds,
                                               @Param("toolType") Integer toolType);

    List<DeviceModelDTO> wxGetListDeviceModelDTO(@Param("orgIds") String[] orgIds,@Param("code") String code);

    DeviceModelDTO getOneDeviceModelDTO(@Param("deviceId") String deviceId);

    /**
     * @return
     */
    List<DeviceRecordDTO> getDevAbnormalelectricQuantity(@Param("orgIds") String[] orgIds,
                                                         @Param("deviceName") String deviceName,
                                                         @Param("deviceCode") String deviceCode,
                                                         @Param("electricityPercent") BigDecimal electricityPercent,
                                                         @Param("typeId") String typeId);

    List<DeviceRecordDTO> getOneDevAbnormalelectricQuantity(@Param("deviceId") String deviceId,
                                                            @Param("startTime") Date startTime,
                                                            @Param("endTime") Date endTime,
                                                            @Param("electricityPercent") BigDecimal electricityPercent);


    String getExceptionCode(@Param("code")Integer code);


}
